import 'package:flutter/material.dart';
import 'package:flutter_study/flutter/_09%E8%B7%AF%E7%94%B1%E5%AF%BC%E8%88%AA/pages/Product.dart';

import 'pages/Search.dart';

void main() => runApp(MyApp());

//命名路由的使用
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      //配置路由
      routes: {
        '/search': (context) => SearchPage(),
        '/product': (context) => ProductPage(
              arguments: {"id": "12"},
            ),
      },
      home: Scaffold(
        appBar: AppBar(
          title: Text("命名路由"),
        ),
        body: Column(
          children: <Widget>[
            Builder(builder: (context) {
              return GestureDetector(
                child: Container(
                  child: Text("跳转"),
                  color: Colors.blue,
                  height: 100,
                  width: 100,
                ),
                onTap: () {
                  //使用跳转的页面替换当前页面
                  Navigator.of(context).pushReplacementNamed('/product');
                },
              );
            }),
          ],
        ),
      ),
    );
  }
}
